package com.jianshuai.controller;

import com.jianshuai.service.IDeviceService;
import com.jianshuai.domain.Device;
import com.jianshuai.utils.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/device")
public class DeviceController {

    @Autowired
    private IDeviceService iDeviceService;

    @GetMapping("/getDeviceInfoById")
    public JSONResult<Device> getDeviceInfoById(@RequestParam("id") Long id){

        System.out.println("id为============::"+ id);
        return iDeviceService.getDeviceInfoById(id);
    }

    @PostMapping("/add")
    public JSONResult add(@RequestBody Device device){
        System.out.println("device:======::"+device);
        return iDeviceService.add(device);
    }


    @GetMapping("/getByBuildId/{id}")
    public List<Device> getByBuildId(@PathVariable("id") Long id){
        return iDeviceService.getByBuildId(id);
    }

    @GetMapping("/getDeviceListByDeviceType/{type}")
    public List<Device> getDeviceListByDeviceType(@PathVariable("type") Long type){
        return iDeviceService.getDeviceListByDeviceType(type);
    }


}
